package com.xcjw.com.Base;

import android.app.Activity;

import java.lang.ref.WeakReference;

/**
 *
 * @filename MyActivityManager
 * @date on 2018/9/17 13:54
 *****/
public class MyActivityManager {


      private static MyActivityManager sInstance = new MyActivityManager();

      private WeakReference<Activity> sCurrentActivityWeakRef;


      private MyActivityManager() {

      }

      public static MyActivityManager getInstance() {
            return sInstance;
      }

      public Activity getCurrentActivity() {
            Activity currentActivity = null;
            if (sCurrentActivityWeakRef != null) {
                  currentActivity = sCurrentActivityWeakRef.get();
            }
            return currentActivity;
      }

      public void setCurrentActivity(Activity activity) {
            sCurrentActivityWeakRef = new WeakReference<Activity>(activity);
      }

}